package org.onepiece.admin.integration.manager;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onepiece.admin.entity.dto.context.OrderContext;
import org.onepiece.admin.integration.handler.DictHandler;
import org.onepiece.admin.integration.handler.LevelHandler;
import org.springframework.stereotype.Component;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zhujianke@gaodun.com
 * @since 2023/3/16 21:00
 */
@AllArgsConstructor
@Slf4j
public abstract class AbstractOrderService implements OrderService {

    private final DictHandler dictHandler;
    private final LevelHandler levelHandler;

    @Override
    public void doHandle(OrderContext context) {
        log.warn("AbstractOrderService#doHandle context:{}", context);
        dictHandler.handle();
        this.handlePayOrder(context);
        // 更新等级
        CompletableFuture.runAsync(levelHandler::handle);
    }
}
